package com.e3.template.tgf;

import java.util.List;

import com.e3.web.core.model.SuperModel;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.Element;

public abstract class TGFSimpleFormPanel<D extends SuperModel> extends TGFFormPanel<D> {
	
	private FormPanel formPanel ;

	@Override
	protected void onRender(Element parent, int index) {
		super.onRender(parent, index);
		this.setLayout(new FitLayout());
		//setSize(450, 600);

		this.add(getFormPanel());
	}
	
	protected FormPanel getFormPanel(){
		if(formPanel == null){
			formPanel = createSingleFormPanel();
			initFormPanel(formPanel, getFormFields());
		}
		return formPanel;
	}
	
	public void clearFormData() {
		getFormPanel().clear();
	}

	public abstract List<Field<?>> getFormFields();
	
}
